<template>
     <!-- banner -->
     <div class="banner">
      <div class="container-fluid ">
        <div class="in-title">
          <h5 class="banner-h5">ZTC Chain Explorer</h5>

          <div class="input-group">
            <div class="input-group-prepend">
             <select class="custom-select" v-model="selectType" name="f" id="0">
               <option value="0">Addresses</option>
               <option value="1">Txn Hash</option>
               <option value="2">Block</option>
             </select>
            </div>
            <input class="input-control" type="text" v-model="inputValue" placeholder="   Search by Address / Txn Hash / Block ">
            <div class="input-group-append">
              <button class="input-btn" @click="handleInput"></button>
            </div>
          </div>
          <p class="banner-p">$ZTC, the governance token for ZTC GLOBAL.</p>
        </div>
      </div>
    
    </div>
</template>

<script>
import '@/assets/css/Banner.css'
export default {
    name: 'Banner',
    data(){
      return{
           selectType:'0',
           inputValue: ""
      }
    },
    methods:{
        handleInput(){
          console.log(this.$route.name)
          console.log(this.selectType)
        if(this.selectType==0){
           if(this.$route.name!="transactionInfoAddress"){
            if(this.inputValue!=''&&this.inputValue!=null){
               this.$router.push({name:'transactionInfoAddress',params:{inputValue:this.inputValue}})
            }
          }else{
         this.$emit('searchInfoAddress',this.inputValue)
        }
        }
         if(this.selectType==2){
           if(this.$route.name!="blockInfo"){
            if(this.inputValue!=''&&this.inputValue!=null){
               this.$router.push({name:'blockInfo',params:{blockId:this.selectType,inputValue:this.inputValue}})
            }
          }else{
          this.$emit('searchblockInfo',this.inputValue)
        }
      }
      if(this.selectType==1){
        if(this.$route.name!="transactionInfo"){
        if(this.inputValue!=''&&this.inputValue!=null){
        this.$router.push({name:'transactionInfo',params:{inputValue:this.inputValue},query:{ts:Date.now()}})
        }
      }else{
         this.$emit('searchTransactionInfo',this.inputValue)
      }
     }
   },
    }

}
</script>

<style>

</style>